/*******************************************************************************
** 
** File name: 	UTEST_LOG.h
**	
** Description:	RTOS Ver.3 Unit Tests debug output configuration macro.
**
** RTOS API Services to be checked:
**
**		- RTOS_DebugPrint()
**		- RTOS_DebugLogData()
**		- RTOS_DebugLogDump()
**
** Notes:		None
**
*******************************************************************************
**
** Change history:
**	
** 10/09/2012 -AK-  File created
**
*******************************************************************************/
#include "rtos.h"

#ifndef	  __UTEST_LOG_H__
#define   __UTEST_LOG_H__	

/******************************************************************************
** RTOS_DebugXXX() wrappers 
******************************************************************************/

#define RTOS_DebugLogInit()								\
	RTOS_DebugOutSync();

#define RTOS_DebugLog( __string__ )						\
{														\
	static char FLASH const RTOS_DBG[]	= __string__;	\
	RTOS_DebugOutAddr( (void *)&RTOS_DBG[0] );			\
}

#define RTOS_DebugLogData( __buff__ , __size__ )		\
	RTOS_DebugOutData(	(void *)	__buff__ ,			\
						(RTOS_U8_t)	__size__ - 1)

#define RTOS_DebugLogByte( __byte__ )					\
	RTOS_DebugOutData( (void *) &__byte__ ,	0 )

#define RTOS_DebugLogWord( __word__ )					\
	RTOS_DebugOutData( (void *) &__word__ ,	1 )
	
#define RTOS_DebugLogDump() RTOS_DebugOutDump()	

#define RTOS_DebugPrint( __fmt__, ... )					\
{														\
	static char FLASH const RTOS_FMT[]	= __fmt__;		\
	RTOS_DebugOutArgs( (const char *) &RTOS_FMT[0], 	\
						##__VA_ARGS__ );				\
}

/******************************************************************************
** RTOS_DebugXXX() extentions for MODULEs
******************************************************************************/
#define RTOS_DEBUG_PRINT( __module__, args... )					\
	RTOS_DebugPrint_ ## __module__ ( args )
#define RTOS_DEBUG_LOG_DATA( __module__, __buff__, __size__ )	\
	RTOS_DebugLogData_ ## __module__ ( __buff__, __size__ )
#define RTOS_DEBUG_LOG_DUMP( )									\
	RTOS_DebugLogDump_ ## __module__ ( )

/******************************************************************************
** Empty macro to mute output when it should be disabled
******************************************************************************/
#define	RTOS_DebugLogOFF( ... )

/******************************************************************************
** Mapping MODULE' debug output depending on configuration option
******************************************************************************/

#ifdef	LOG_DEFUALT				
#	define RTOS_DebugPrint_DEFAULT		RTOS_DebugPrint
#	define RTOS_DebugLogData_DEFAULT	RTOS_DebugLogData
#	define RTOS_DebugLogDump_DEFAULT	RTOS_DebugLogDump
#else
#	define RTOS_DebugPrint_DEFAULT		RTOS_DebugLogOFF
#	define RTOS_DebugLogData_DEFAULT	RTOS_DebugLogOFF
#	define RTOS_DebugLogDump_DEFAULT	RTOS_DebugLogOFF
#endif

#ifdef	LOG_MAIN
#	define RTOS_DebugPrint_MAIN			RTOS_DebugPrint
#	define RTOS_DebugLogData_MAIN		RTOS_DebugLogData
#	define RTOS_DebugLogDump_MAIN		RTOS_DebugLogDump
#else
#	define RTOS_DebugPrint_MAIN			RTOS_DebugLogOFF
#	define RTOS_DebugLogData_MAIN		RTOS_DebugLogOFF
#	define RTOS_DebugLogDump_MAIN		RTOS_DebugLogOFF
#endif

#ifdef	LOG_TASK
#	define RTOS_DebugPrint_TASK			RTOS_DebugPrint
#	define RTOS_DebugLogData_TASK		RTOS_DebugLogData
#	define RTOS_DebugLogDump_TASK		RTOS_DebugLogDump
#else
#	define RTOS_DebugPrint_TASK			RTOS_DebugLogOFF
#	define RTOS_DebugLogData_TASK		RTOS_DebugLogOFF
#	define RTOS_DebugLogDump_TASK		RTOS_DebugLogOFF
#endif

#ifdef	LOG_ISR
#	define RTOS_DebugPrint_ISR			RTOS_DebugPrint
#	define RTOS_DebugLogData_ISR		RTOS_DebugLogData
#	define RTOS_DebugLogDump_ISR		RTOS_DebugLogDump
#else
#	define RTOS_DebugPrint_ISR			RTOS_DebugLogOff
#	define RTOS_DebugLogData_ISR		RTOS_DebugLogOff
#	define RTOS_DebugLogDump_ISR		RTOS_DebugLogOff
#endif

#endif	/* __UTEST_LOG_H__ */